#ifndef QPITCHDETECTOR_H
#define QPITCHDETECTOR_H

#include <QWidget>
#include "ui_qpitchdetector.h"
#include "fmod.h"
#include "fmod.hpp"
#include "fmod_errors.h"

#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <sstream>
#include <string>

#include "../AudioModel/AudioUtils.h"
#include "pitchthread.h"

#define OUTPUTRATE          44100
#define SPECTRUMSIZE        8192
#define SPECTRUMRANGE       ((float)OUTPUTRATE / 2.0f)      /* 0 to nyquist */

#define BINSIZE      (SPECTRUMRANGE / (float)SPECTRUMSIZE)

using namespace std;

class QPitchDetector : public QWidget
{
	Q_OBJECT
public:
	QPitchDetector(QWidget *parent = 0);
	QPitchDetector(FMOD::System *);
	~QPitchDetector();
	public slots:
		void startDetection();
		void stopDetection();

private:
	Ui::QPitchDetector ui;
	FMOD::System * system;
	FMOD::Sound           *sound;
    FMOD::Channel         *channel;
    FMOD_RESULT            result;
    FMOD_CREATESOUNDEXINFO exinfo;
    int                    key, driver, recorddriver, numdrivers, count, bin;
    unsigned int           version; 
	PitchThread *pdec;
};

#endif // QPITCHDETECTOR_H
